#!/usr/bin/perl
#
# (C) Copyright 2010- Hewlett-Packard Development Company, L.P.
#
#  $Id:$
#

use strict;

my $myscriptname = "test_script";

package Test_Script;

use strict;
use 5.000800;
use warnings;

use lib "/opt/hp/nv/lib/perl";
use Script_Base;
use config ':all';

our @ISA = qw(Script_Base);

sub new($)
{
    my $class = shift;

    my $self = Script_Base->new(SCRIPT => $myscriptname,
                                STATUS_FILE => "script_new"
                                );
    bless ($self, $class);

    return $self;
}

sub pre_check($)
{
    my $self = shift;

    print "This is pre_check\n";
    if (!$self->{squser}) {
        logerr_n_die("Please provide squser, type --help for more details");
    }

    return (OK);
}

sub perform_config($)
{
    my $self = shift;

    my $force_flag = get_force_flag();

    # CHANGE PREFIX TO USERID OR INSTANCEID OR ELSE
    my $status_value = $self->get_status;

    return(OK) if (!$force_flag && ($status_value == DONE));
	
    print "This is a test script for $self->{squser}\n";

    $self->set_status("completed");
    return (OK);
}

sub post_check($)
{
    my $self = shift;

    print "This is post check\n";

    return (OK);
}

package main;

use strict;
use 5.000800;
use warnings;

use Getopt::Long;

sub usage
{

    print <<"EOF";

This is a test script, usage:
$myscriptname -h -squser=<squser> [-test]

EOF
    exit (Script_Base::UNKNOWN);
}

my $revision = '$Revision: 10000 $';
$revision =~ s/\$//g;

my %lv_opts = (rev => $revision);
&GetOptions(\%lv_opts, "squser=s",
                       "test",
                       "help" => \&usage) or usage();

my $script = Test_Script->new();
$script->set_args(\%lv_opts);
$script->run();

